#!/usr/local/bin/python3
#-*- coding:utf8 -*-
# Author Aaron 
# 2017-04-15 22:55:47
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
servopin = 7
GPIO.setup(servopin, GPIO.OUT, initial=False)
p = GPIO.PWM(servopin, 50)  # 50HZ
p.start(0)
time.sleep(2)
p.ChangeDutyCycle(2.3)  # 设置转动角度
time.sleep(0.02)
time.sleep(2)
p.ChangeDutyCycle(5)  # 设置转动角度
time.sleep(0.02)
time.sleep(2)
p.ChangeDutyCycle(7.5)  # 设置转动角度
time.sleep(0.02)
time.sleep(2)
p.ChangeDutyCycle(10)  # 设置转动角度
time.sleep(0.02)
time.sleep(2)
p.ChangeDutyCycle(11.5)  # 设置转动角度
time.sleep(0.02)
time.sleep(20)
# p.ChangeDutyCycle(0)
# time.sleep(0.2)
# time.sleep(10000000)
#
# while (True):
#     for i in range(0, 181, 10):
#         p.ChangeDutyCycle(2.5 + 10 * i / 180)  # 设置转动角度
#         time.sleep(0.02)  # 等该20ms周期结束
#         # p.ChangeDutyCycle(0)  # 归零信号
#         time.sleep(0.2)
#
#     for i in range(181, 0, -10):
#         p.ChangeDutyCycle(2.5 + 10 * i / 180)
#         time.sleep(0.02)
#         # p.ChangeDutyCycle(0)
#         time.sleep(0.2)
GPIO.cleanup()


